#ifndef _DRIVER_TOUCHPAD_H
#define _DRIVER_TOUCHPAD_H

#include <stdint.h>



#define CST816D_EN  0

#define CST816T_EN   1

/*********************
 *      DEFINES
 *********************/
#if CST816D_EN
#define CST816_RST_SET			gpio_write_pin(GPIO_A, GPIO_PIN_5, GPIO_PIN_SET)
#define CST816_RST_CLR			gpio_write_pin(GPIO_A, GPIO_PIN_5, GPIO_PIN_CLEAR)

#elif CST816T_EN

 
#define CST816T_EXTI_LINE  		 EXTI_LINE14_PB6
#define CST816T_EXTI_GPIO_NUM  GPIO_PIN_6
#define CST816T_EXTI_PORT  		 GPIO_B

#define CST816T_SDA_GPIO_NUM  	GPIO_PIN_5
#define CST816T_SCL_GPIO_NUM  	GPIO_PIN_4
#define CST816T_IIC_PORT  		  GPIO_A

#define CST816T_RST_GPIO_NUM   GPIO_PIN_7
#define CST816T_RST_PORT  		 GPIO_B

#define CST816_RST_SET			gpio_write_pin(CST816T_RST_PORT, CST816T_RST_GPIO_NUM, GPIO_PIN_SET)
#define CST816_RST_CLR			gpio_write_pin(CST816T_RST_PORT, CST816T_RST_GPIO_NUM, GPIO_PIN_CLEAR)


#endif

/**********************
 *      TYPEDEFS
 **********************/

/**********************
 * GLOBAL PROTOTYPES
 **********************/
void cst816_init(void);
void cst816_exti_isr_handle(void);
 

/************************************************************************************
 * @fn      touchpad_read_data
 *
 * @brief   used to read data from touchpad, these data are update in interrupt
 *
 * @param   rx_buffer: buffer used to store received data.
 *          length: length should be set to 8.
 */
void touchpad_read_data(uint8_t *rx_buffer, uint8_t length);

/************************************************************************************
 * @fn      touchpad_read_data_raw
 *
 * @brief   used to read data directly from touchpad registers.
 *
 * @param   rx_buffer: buffer used to store received data.
 *          length: length should be set to 8.
 */
void touchpad_read_data_raw(uint8_t *rx_buffer, uint8_t length);

/************************************************************************************
 * @fn      touchpad_init
 *
 * @brief   init GPIO, Interrupt and I2C used by touchpad
 *
 * @param   callback: used to notify application layer to fetch data
 */
void touchpad_init(void (*callback)(void));

#endif  // _DRIVER_TOUCHPAD_H
